/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.Query;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import model.Employeeproject;

/**
 *
 * @author HuyNVK
 */
@Stateless
public class EmployeeprojectFacade extends AbstractFacade<Employeeproject> implements EmployeeprojectFacadeRemote {
    @PersistenceContext(unitName = "ejb-servPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public EmployeeprojectFacade() {
        super(Employeeproject.class);
    }

    @Override
    public Employeeproject merge(Employeeproject employeeproject) {
        return em.merge(employeeproject);
    }
    
    @Override
    public void deleteByID(String id) {
        Employeeproject em_pro = find(id);
        em_pro = em.merge(em_pro);
        em.remove(em_pro);
    }

    @Override
    public void insert(Employeeproject employeeproject) {
        em.persist(employeeproject);
    }
    
    @Override
    public List<model.Employeeproject> findListEmployeeByProjectID(String id)throws Exception{
        Query query = (Query) em.createQuery("Select ep from Employeeproject ep where ep.project.projectID= '"+id+"'");
        List<model.Employeeproject> obj = query.getResultList();
        return obj;
    }
    
 
}
    

